package com.huanyang.user.controller;

import com.huanyang.redis.util.RedisShareLockUtil;
import com.huanyang.user.entity.po.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Slf4j
public class TestController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RedisShareLockUtil redisShareLockUtil;

    @GetMapping("/test")
    public String test() {
        return "hello world";
    }

    @GetMapping("/testRedis")
    public void testRedis() {
        redisTemplate.opsForValue().set("name", "张三");
    }

    @GetMapping("/testLog")
    public void testLog() {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
            log.info("这是第{}条日志", i);
        }
        long endTime = System.currentTimeMillis();
        log.info("当前日志打印耗时：{}",endTime - startTime);
    }

    @PostMapping("/testQuery")
    public void testQuery(@RequestBody SysUser sysUser) {
        // 2023-10-08 10:38:09
        System.out.println(sysUser);
    }

}
